package org.example.cicdi.service.impl.ext;


import lombok.extern.slf4j.Slf4j;
import org.example.codegenerate.modelext.WebVo.domian.column.ColumnVoDomain;
import org.example.codegenerate.modelext.WebVo.domian.table.WebModelVo;


import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import java.lang.reflect.Field;

@Slf4j
public class ManyToOneService {
    //private Class Many
    public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, WebModelVo webModelVo) {
        if (field.getAnnotation(ManyToOne.class) != null ){
            if(field.getAnnotation(JoinColumn.class)==null){
                log.error(" 缺少jointColumn的注解");
            }else {
                ManyToOne manyToOne = field.getAnnotation(ManyToOne.class);
                //field.getGenericType().g

                JoinColumn joinColumn=field.getAnnotation(JoinColumn.class);
            }
        }
        /*//递归处理oneToMany
        if (field.getAnnotation(OneToMany.class) != null) {
            if (field.getType().equals(List.class)) {
                Type type = field.getGenericType();
                //field.get()
                if (type instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType) type;
                    // 获取泛型里的class类型对象
                    Class<?> fClass = (Class<?>)pt.getActualTypeArguments()[0];
                    WebModelVo sonModel = createModel(fClass);
                    TableVoDomain sonTable = sonModel.getTableVoDomain();
                    model.getTableVoDomain().getSonTabeleVoDomain().add(sonTable);
                }
            }
        }*/

            return null;
    }
}
